package example.problems

import scala.collection.mutable.Map
import scala.collection.mutable.Set

class numsSolution{
  def towSums(nums: Seq[Int], target: Int): Set[Int] = {
    val num2IndexMap   = Map.empty[Int,Int]
    val indexSet = Set.empty[Int]
    var index = 0
    nums.foreach(e=>{
        index +=1
        val complement = target - e
        val indexOpt = num2IndexMap.get(complement)
        if( indexOpt.nonEmpty ) {
          indexSet.add(index)
          indexSet.add(indexOpt.get)
        }else{
          num2IndexMap.put(e,index)
        }

    })
    indexSet
  }
}